{ext->get_field_value assign="value" name=$el.name parent=$data.page.id type=$el.type_of_value}
<input type="hidden" name="{$el.name}" value="">
<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td height="1" bgcolor="#DBE1E5"><img src="client/img/spacer.gif" class="spacer" alt="" /></td>
	</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#F8F9F9">	
	<tr>
		<td width="15"><img src="client/img/spacer.gif" class="spacer" alt="" /></td>
		<td width="222" height="25" class="defaultFormLabel">{t t='Užsiregistravusį klientą automatiškai priskirti prie'}:</td>
		<td width="15"><img src="client/img/spacer.gif" class="spacer" alt="" /></td>
		<td width="1" align="left">
				{ext->class_function class="clients" func="get_clients_group" assign="groups_list"}
				<select style="width:300px; margin:2px 15px 2px 0px " name="group_id" id="group_id">					
					<option value="-1" selected>{t t='Išsirinkite frupę iš sąrašo ir spauskite Aktyvuoti taisyklę'}</option>					
					{foreach from=$groups_list item="group"}									
						<option value="{$group.id}">{if $group.parent}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}{$group.name}</option>
					{/foreach}							
				</select>		
			
		</td>		
		<td width="10"><img src="client/img/spacer.gif" class="spacer" alt="" /></td>
		<td height="25" class="defaultFormLabel" align="left"><a href="#" target="_self" onClick="activateRule(document.getElementById('group_id').value); return false;">{t t='Aktyvuoti taisyklę'}</a></td>
	</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td  bgcolor="#F8F9F9">
		<span id="stage"></span>
		</td>		
	</tr>
</table>
<span id="master" style="width:100%; visibility:hidden; position:absolute ">
 <table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td height="1" bgcolor="#DBE1E5"><img src="client/img/spacer.gif" class="spacer" alt="" /></td>
	</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#F8F9F9">	
	<tr>
		<td width="20" height="20" style="padding:0px 0px 0px 30px "><img src="_tvs_system_core_/design/img/admin/_icon_delete.gif"></td>
		<td width="40" style="border-right:1px solid #DBE1E5 "><a href="#" target="_self" onClick="fDeleteRule (this.parentNode.parentNode.parentNode.parentNode.parentNode)">{t t='Šalinti'}</a></td>
		<td style="padding:0px 0px 0px 15px "><b><nobr><span>Grupe trupe</span></b></td>
	</tr>
</table>
<input type="hidden" name="" value="">
</span>

<script language="javascript" type="text/javascript">
var oMaster=document.getElementById('master');
var oStage=document.getElementById('stage');
var aAllGroups=new Array();
var aRegister=new Array();
var sHiddenName='{$el.name}';
var sErrExists='{t t='Ši grupė jau yra'}';
var sErrChose='{t t='Pasirinkite grupę iš sąrašo'}';
{literal}
function activateRule (nID){
	if(nID<0) {
		alert(sErrChose);
		return;
	}
	
	var tmpNode=oMaster.cloneNode(true);
	var oSpans=tmpNode.getElementsByTagName('SPAN');	
	var oHidden=tmpNode.getElementsByTagName('INPUT');
		
	if (aRegister[nID]==null)	aRegister[nID]=nID;
	else {
		alert(sErrExists);
		return
	}
	
	oHidden[0].setAttribute('name',sHiddenName+'[]');
	oHidden[0].setAttribute('value',nID);
	
	oSpans[0].innerHTML=aAllGroups[nID];
	
	tmpNode.style.visibility="visible";
	tmpNode.style.position="relative";
	oStage.appendChild(tmpNode);
}
function registerGroups (sName,nId){
	aAllGroups[nId]=sName;
}
function fDeleteRule (oSelf){		
	var oHidden=oSelf.getElementsByTagName('INPUT');		
	var nID=oHidden[0].value;
	aRegister[nID]=null;
	oSelf.parentNode.removeChild(oSelf);		
}
function fLoadSaved (sValues) {
	var aValues=new Array();
	aValues=sValues.split(';');
	for(i=0; i<aValues.length; i++) {
		if (aValues[i]>0) activateRule (aValues[i])
	}
}
{/literal}
{foreach from=$groups_list item="group"}									
	registerGroups ('{$group.name|escape:"quotes"}',{$group.id})
{/foreach}		
fLoadSaved ("{$value}");
</script>

